<?php


namespace app\Activity\controller;


use app\activity\model\ActivityClassify as ActivityClassifyModel;
use app\ApiRest;


class WxAppActivityClassify extends ApiRest
{
    public function listActivityClassify()
    {
        //
        $param = $this->_param;
        $page_config = array(
            'page' => 1,
            'page_count' => 20
        );
        //设置页码
        if (isset($param['page']) && $param['page'] > 0) $page_config['page'] = $param['page'];
        //设置每页的数据
        if (isset($param['page_count']) && $param['page_count'] > 0) $page_config['page_count'] = $param['page_count'];
        $filter = [
            ['uniacid', '=', $this->_uniacid],
            ['status', '=', 1]
        ];
        $model = new ActivityClassifyModel();
        $page_config['total'] = $model->countByFilter($filter);
        $rsts = $model->getListByFilter($filter, $page_config);
        $page_config['total_page'] = (int)($page_config['total'] / $page_config['page_count']);
        if (($page_config['total'] % $page_config['page_count']) > 0) $page_config['total_page'] = $page_config['total_page'] + 1;
        //设置返回参数
        $result = $page_config;
        //返回数据
        $result['data'] = $rsts;
        return $this->success($result);


    }

}